<script type="text/javascript" src="{$WebPublic}My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#frm').ajaxForm({
			success: complete,
			dataType: 'json'
		});
		
		function complete(data){
			CloseLoadBox();
			if (data.status==1){
				SucceedBox(data.info);
				<empty name="HiddenName">
					$('#frm').resetForm();
					focusFirstItem();
				</empty>
            }else{
				ErrorBox(data.info);
			}
		};
		
		 $('#frm').submit(function(){
			 LoadBox();
	     	return false;  //为了防止普通浏览器进行表单提交和产生页面导航（防止页面刷新？）返回false  
	     });
		 
		 $("#btnMakeAppSecret").click(function(){
			LoadBox();
			$.get("{$Url}makeAppSecret",null,function(data){
				$("#AppSecret").val(data.data);
				CloseLoadBox();
			},"json");
		});
		
	  $("#btnMakeAppID").click(function(){
			LoadBox();
			$.get("{$Url}makeAppID",null,function(data){
				$("#AppID").val(data.data);
				CloseLoadBox();
			},"json");
		});
		 
		 //选中表单第一项
		 function focusFirstItem(){
			 var idName = "#AppID";
			 $(idName).focus();
		 }
		 
		 //设置默认值
		 function setDefault(){
			 $("input[name='IsEnable'][value={$Data.IsEnable}]").attr("checked",'checked');
		 }
		 
		 //页面初始化
		 function pageInit(){
			focusFirstItem();
			setDefault();
		 }
		 pageInit();
	});
	
	//选择全部
	function SelectAll(){
		if( $("#chkAll").is(':checked') ){
			$(".ApiList").attr('checked', true);
		}else{
			$(".ApiList").attr('checked', false);
		}
	}
</script>
<div class="box-header"><h4>基本信息</h4></div>
<div class="box-content">
	<table class="boxtable">
			<tr>
				<th class="w120">AppID</th>
				<td><input type="text" class="textinput" style="width:80px;" name="AppID" id="AppID" value="{$Data.AppID}" />
                 <input type="button" id="btnMakeAppID" style="padding:2px 8px; margin-left:3px; cursor:pointer;"  value="随机生成AppID" />
				<span class='Caution'>长度为8个数字字符！</span>
				</td>
			</tr>
			<tr>
				<th class="w120">AppSecret</th>
				<td><input type="text" class="textinput" style="width:260px;"  name="AppSecret" id="AppSecret" value="{$Data.AppSecret}" />
                <input type="button" id="btnMakeAppSecret" style="padding:2px 8px; margin-left:3px; cursor:pointer;"  value="随机生成AppSecret" />
				<span class='Caution'>App和服务器的通信秘钥，长度为32个字符！</span>
				</td>
			</tr>
            
            <tr>
				<th class="w120">Api接口权限</th>
				<td class="ApiListWrap">
                	<style>
                    	.ApiListWrap label{ display:block; padding:3px 0; margin:0; vertical-align:middle;}
						.ApiListWrap input{ vertical-align:middle;}
						.ApiListWrap .ApiDescription{ color:#666; padding-left:1em;}
                    </style>
                    <label><input type="checkbox"  name="chkAll" id="chkAll" onclick="SelectAll()"  /><span style="color:#00F;"> 全选</span></label>
                	<volist name="Api" id="a">
                    	<label>
                        	<input type="checkbox" value="{$a.ApiID}" class="ApiList"  name="ApiList[]" <in name="a.ApiID" value="$Data.ApiList">checked="checked"</in> />
                             [{$i}] {$a.ApiName} {$a.ApiFunction}
                        	<notempty name="a.ApiDescription"><span class="ApiDescription">说明：{$a.ApiDescription}</span></notempty>
                        </label>
                    </volist>
                </td>
			</tr>
            
           <tr>
				<th class="w120">创建时间</th>
				<td>
<input type="text" class="textinput Wdate" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})"  style="width:150px" name="SecretTime" value="{$Data.SecretTime}"  />			                </td>
			</tr>
            
			<tr>
				<th class="w120">备注</th>
				<td><textarea  style="width:100%; height:50px;" name="SecretRemark" id="SecretRemark" />{$Data.SecretRemark}</textarea></td>
			</tr>
			<tr>
				<th>是否启用</th>
				<td>
					<label><input type="radio" name="IsEnable" value="1" checked="checked"  />启用</label>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<label><input type="radio" name="IsEnable" value="0" />禁用</label>
				</td>
			</tr>
	</table>
</div>